x86 svm: Add support for Pause Filtering to AMD SVM
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 27 May 2009 10:27:13 +0000 (11:27 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 27 May 2009 10:27:13 +0000 (11:27 +0100)
commitc1134c228ca3bd802f867572d33be043f4a56442
tree43828fc255bc0dbed5776d296d2497ad61ae187e
parent86475c92139d83035e8d7bfc5c7e72795630e80e
x86 svm: Add support for Pause Filtering to AMD SVM

New AMD processors will support the Pause Filter Feature.
This feature creates a new field in the VMCB called Pause
Filter Count.  If Pause Filter Count is greater than 0 and
ntercepting PAUSEs is enabled, the processor will increment
an internal counter when a PAUSE instruction occurs instead
of intercepting.  When the internal counter reaches the
Pause Filter Count value, a PAUSE intercept will occur.

This feature can be used to detect contended spinlocks,
especially when the lock holding VCPU is not scheduled.
Rescheduling another VCPU prevents the VCPU seeking the
lock from wasting its quantum by spinning idly.

Experimental results show that most spinlocks are held
for less than 1000 PAUSE cycles or more than a few
thousand.  Default the Pause Filter Counter to 3000 to
detect the contended spinlocks.

Processor support for this feature is indicated by a CPUID
bit.

On a 24 core system running 4 guests each with 16 VCPUs,
this patch improved overall performance of each guest's
32 job kernbench by approximately 1%.  Further performance
improvement may be possible with a more sophisticated
yield algorithm.

Signed-off-by: Mark Langsdorf <mark.langsdorf@amd.com>
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/hvm/svm/vmcb.c
xen/include/asm-x86/hvm/svm/svm.h
xen/include/asm-x86/hvm/svm/vmcb.h